
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 01/12/2013 19:25:33
-- Generated from EDMX file: C:\IS\RSA7\Rsa\Rsa\Model1.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [baseDados];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_jantarRelacao]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ementaDBSet] DROP CONSTRAINT [FK_jantarRelacao];
GO
IF OBJECT_ID(N'[dbo].[FK_almocoRelacao]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ementaDBSet] DROP CONSTRAINT [FK_almocoRelacao];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[ementaDBSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ementaDBSet];
GO
IF OBJECT_ID(N'[dbo].[menuDBSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[menuDBSet];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'ementaDBSet'
CREATE TABLE [dbo].[ementaDBSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [campus] int  NULL,
    [cantina] int  NULL,
    [data] datetime  NOT NULL,
    [jantar_Id] int  NOT NULL,
    [almoco_Id] int  NOT NULL
);
GO

-- Creating table 'menuDBSet'
CREATE TABLE [dbo].[menuDBSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [sopa] nvarchar(max)  NULL,
    [carne] nvarchar(max)  NULL,
    [peixe] nvarchar(max)  NULL,
    [vegetariano] nvarchar(max)  NULL,
    [sobremesa] nvarchar(max)  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'ementaDBSet'
ALTER TABLE [dbo].[ementaDBSet]
ADD CONSTRAINT [PK_ementaDBSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'menuDBSet'
ALTER TABLE [dbo].[menuDBSet]
ADD CONSTRAINT [PK_menuDBSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [jantar_Id] in table 'ementaDBSet'
ALTER TABLE [dbo].[ementaDBSet]
ADD CONSTRAINT [FK_jantarRelacao]
    FOREIGN KEY ([jantar_Id])
    REFERENCES [dbo].[menuDBSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_jantarRelacao'
CREATE INDEX [IX_FK_jantarRelacao]
ON [dbo].[ementaDBSet]
    ([jantar_Id]);
GO

-- Creating foreign key on [almoco_Id] in table 'ementaDBSet'
ALTER TABLE [dbo].[ementaDBSet]
ADD CONSTRAINT [FK_almocoRelacao]
    FOREIGN KEY ([almoco_Id])
    REFERENCES [dbo].[menuDBSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_almocoRelacao'
CREATE INDEX [IX_FK_almocoRelacao]
ON [dbo].[ementaDBSet]
    ([almoco_Id]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------